package com.edunera.models;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class edu_comments implements Serializable {
	
	public int comment_id;
	
	public int user_id;
	
	public int course_id;
	
	public String comment_date;
	
	public int reply_to_id;
	
	public String subject;
	
	public String comment;
	
	public String username;
	
	public static ArrayList<edu_comments> getCommentListFromJson(JSONArray commentsInJson){
				
		ArrayList<edu_comments> edu_commentsList=new ArrayList<edu_comments>();
		
		for(int i=0;i<commentsInJson.length();i++){
			edu_comments ec=new edu_comments();
			try{
				JSONObject jo=commentsInJson.getJSONObject(i);
				ec.comment=jo.getString("comment");
				ec.comment_date=jo.getString("comment_date");
				ec.user_id=jo.getInt("user_id");
				ec.subject=jo.getString("subject");
				ec.username=jo.getString("username");
				edu_commentsList.add(ec);
			}catch(JSONException ex){
				
			}
			
		}	
		return edu_commentsList;
	}
}
